﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Painter
{
    /// <summary>
    /// TitleWindow.xaml 的交互逻辑
    /// </summary>
    public partial class TitleWindow : UserControl
    {
        public bool OpenStatus { get; set; }
        public static DependencyProperty HeaderProperty =
            DependencyProperty.Register("Header", typeof(string), typeof(TitleWindow), new PropertyMetadata(""));

        public string Header
        {
            get { return (string)GetValue(HeaderProperty); }
            set{SetValue(HeaderProperty, value);}
        }

        public TitleWindow()
        {
            OpenStatus = true;
            InitializeComponent();
        }
        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            OpenStatus = !OpenStatus;
            (e.Source as Image).Source = OpenStatus?new BitmapImage(new Uri("pack://application:,,,/Resource/侧边栏_收起.png")):
                new BitmapImage(new Uri("pack://application:,,,/Resource/侧边栏_展开.png"));
            Width = (!OpenStatus?30:double.NaN);

            if ((sender as FrameworkElement).Parent is Grid){
                ((sender as FrameworkElement).Parent as Grid).Children[0].Visibility = (!OpenStatus ? Visibility.Collapsed:Visibility.Visible);
            }
            if ((sender as FrameworkElement).Parent is Grid){
                (((sender as FrameworkElement).Parent as Grid).Parent as Grid).Children[1].Visibility = (!OpenStatus ? Visibility.Collapsed : Visibility.Visible);
            }
        }
    }
}
